home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / share / ewl / examples / ewl_statusbar_test.c < prev    next >
C/C++ Source or Header  |  2006-01-09  |  3KB  |  91 lines

  1. #include "ewl_test.h"
  2.  
  3. static Ewl_Widget *statusbar_button;
  4. static int current_num = 0;
  5.  
  6. static void
  7. __button_push_cb(Ewl_Widget *w __UNUSED__, void *ev_data __UNUSED__,
  8.                         void *user_data)
  9. {
  10.     Ewl_Statusbar *sb;
  11.     char msg[20];
  12.     
  13.     sb = user_data;
  14.  
  15.     snprintf(msg, 20, "at %d", current_num++);
  16.     ewl_statusbar_push(sb, msg);
  17. }
  18.  
  19. static void
  20. __button_pop_cb(Ewl_Widget *w __UNUSED__, void *ev_data __UNUSED__,
  21.                         void *user_data)
  22. {
  23.     Ewl_Statusbar *sb;
  24.  
  25.     sb = user_data;
  26.     ewl_statusbar_pop(sb);
  27. }
  28.  
  29. static void
  30. __destroy_statusbar_test_window(Ewl_Widget *w, void *ev_data __UNUSED__,
  31.                         void *user_data __UNUSED__)
  32. {
  33.     ewl_widget_destroy(w);
  34.     ewl_callback_append(statusbar_button, EWL_CALLBACK_CLICKED,
  35.                     __create_statusbar_test_window, NULL);
  36. }
  37.  
  38. void
  39. __create_statusbar_test_window(Ewl_Widget *w, void *ev_data __UNUSED__,
  40.                     void *user_data __UNUSED__)
  41. {
  42.     Ewl_Widget *statusbar_win = NULL, *box = NULL;
  43.     Ewl_Widget *statusbar = NULL, *button = NULL;
  44.  
  45.     statusbar_button = w;
  46.  
  47.     statusbar_win = ewl_window_new();
  48.     ewl_window_title_set(EWL_WINDOW(statusbar_win), "Statusbar Test");
  49.     ewl_window_name_set(EWL_WINDOW(statusbar_win), "EWL Test Application");
  50.     ewl_window_class_set(EWL_WINDOW(statusbar_win), "EFL Test Application");
  51.     ewl_object_minimum_size_set(EWL_OBJECT(statusbar_win), 100, 100);
  52.  
  53.     if (w) {
  54.         ewl_callback_del(w, EWL_CALLBACK_CLICKED, 
  55.                 __create_statusbar_test_window);
  56.         ewl_callback_append(statusbar_win, EWL_CALLBACK_DELETE_WINDOW,
  57.                     __destroy_statusbar_test_window, NULL);
  58.     } else 
  59.         ewl_callback_append(statusbar_win, EWL_CALLBACK_DELETE_WINDOW,    
  60.                     __close_main_window, NULL);
  61.     ewl_widget_show(statusbar_win);
  62.  
  63.     box = ewl_vbox_new();
  64.     ewl_container_child_append(EWL_CONTAINER(statusbar_win), box);
  65.     ewl_widget_show(box);
  66.  
  67.     statusbar = ewl_statusbar_new();
  68.     ewl_container_child_append(EWL_CONTAINER(box), statusbar);
  69.     ewl_statusbar_left_hide(EWL_STATUSBAR(statusbar));
  70.     ewl_widget_show(statusbar);
  71.  
  72.     button = ewl_button_new();
  73.     ewl_button_label_set(EWL_BUTTON(button), "push");
  74.     ewl_callback_append(button, EWL_CALLBACK_CLICKED, __button_push_cb,
  75.                                 statusbar);
  76.     ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_SHRINK);
  77.     ewl_container_child_append(EWL_CONTAINER(box), button);
  78.     ewl_widget_show(button);
  79.  
  80.     button = ewl_button_new();
  81.     ewl_button_label_set(EWL_BUTTON(button), "pop");
  82.     ewl_callback_append(button, EWL_CALLBACK_CLICKED, __button_pop_cb,
  83.                                 statusbar);
  84.     ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_SHRINK);
  85.     ewl_container_child_append(EWL_CONTAINER(box), button);
  86.     ewl_widget_show(button);
  87. }
  88.  
  89.  
  90.  
  91.